package com.dd.admin.business.detailServer.controller;

import cn.hutool.core.bean.BeanUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.dd.admin.common.model.UpdateGroup;
import com.dd.admin.common.model.result.ResultBean;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotBlank;
import com.dd.admin.business.detailServer.entity.SellDetailServer;
import com.dd.admin.business.detailServer.domain.SellDetailServerVo;
import com.dd.admin.business.detailServer.domain.SellDetailServerDto;
import com.dd.admin.business.detailServer.service.SellDetailServerService;

import java.util.List;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单详单服务人员 前端控制器
 * </p>
 *
 * @author 727869402@qq.com
 * @since 2024-11-28
 */
@Api(tags = "订单详单服务人员")
@RestController
public class SellDetailServerController {

    @Autowired
    SellDetailServerService detailServerService;

    @ApiOperation(value = "订单详单服务人员-分页列表")
    @ApiOperationSupport(order = 1)
    @GetMapping("/admin/detailServer/page")
    public ResultBean<IPage<SellDetailServerVo>> page(SellDetailServerDto detailServerDto) {
        IPage<SellDetailServerVo> pageInfo = detailServerService.selectSellDetailServerPage(detailServerDto);
        return ResultBean.success(pageInfo);
    }

    @ApiOperation(value = "订单详单服务人员-列表")
    @ApiOperationSupport(order = 2)
    @GetMapping("/admin/detailServer/list")
    public ResultBean<List<SellDetailServerVo>> list(SellDetailServerDto detailServerDto) {
        List<SellDetailServerVo> list = detailServerService.selectSellDetailServerList(detailServerDto);
        return ResultBean.success(list);
    }

    @ApiOperation(value = "订单详单服务人员-添加")
    @ApiOperationSupport(order = 3)
    @PostMapping("/admin/detailServer/add")
    public ResultBean<SellDetailServer> add(@RequestBody @Validated SellDetailServerDto detailServerDto) {
        SellDetailServer detailServer = BeanUtil.copyProperties(detailServerDto, SellDetailServer.class);
        detailServerService.save(detailServer);
        return ResultBean.success(detailServer);
    }

    @ApiOperation(value = "订单详单服务人员-查询")
    @ApiOperationSupport(order = 4)
    @GetMapping("/admin/detailServer/{detailServerId}")
    public ResultBean<SellDetailServerVo> get(@PathVariable @NotBlank String detailServerId) {
        SellDetailServer detailServer = detailServerService.getById(detailServerId);
        SellDetailServerVo detailServerVo = BeanUtil.copyProperties(detailServer,SellDetailServerVo.class);
        return ResultBean.success(detailServerVo);
    }

    @ApiOperation(value = "订单详单服务人员-修改")
    @ApiOperationSupport(order = 5)
    @PostMapping("/admin/detailServer/update")
    public ResultBean<SellDetailServer> update(@RequestBody @Validated(UpdateGroup.class) SellDetailServerDto detailServerDto) {
        SellDetailServer detailServer = BeanUtil.copyProperties(detailServerDto, SellDetailServer.class);
        detailServerService.updateById(detailServer);
        return ResultBean.success(detailServer);
    }

    @ApiOperation(value = "订单详单服务人员-删除")
    @ApiOperationSupport(order = 6)
    @GetMapping("/admin/detailServer/delete/{detailServerId}")
    public ResultBean<SellDetailServer> delete(@PathVariable @NotBlank String detailServerId) {
        Boolean b = detailServerService.removeById(detailServerId);
        return ResultBean.success(b);
    }
}
